const Warning = require('../models/warning')

exports.findAll = function (para, callback) {
  Warning.findAll(para).then(data => {
        let res = data.map(item => {
            return item.get({
                plain:true
            })
        })
        callback(res);
    })
}

exports.findByConditions = function(conditions, callback) {
  Warning.findAll({where:conditions}).then(data => {
    let res = data.map(item => {
      return item.get({
          plain:true
      })
    })
    callback(res);
  })
}

exports.add = function (data, callback) {
  let {number, deviceNumber, type, time, state} = data
  Warning.create({number, deviceNumber, type, time, state}).then(res => {
        callback(res.get({
            plain: true
        }));
    })
}
